package com.docker.manege.log;

import com.docker.core.constant.APPIDConstant;
import com.docker.core.mvc.APPID;
import com.docker.core.mvc.Remark;
import com.docker.core.mvc.controller.BaseAPIController;
import com.jfinal.aop.Aop;
import com.jfinal.core.ActionKey;

/**
 * @author wangbei
 * @date 2020/12/18 - 16:25
 */
@Remark("日志管理")
@APPID(APPIDConstant.dum_web)
public class LoggerController extends BaseAPIController {

    private LoggerService loggerService = Aop.get(LoggerService.class);

    @Remark("获取文件根目录列表")
    @ActionKey("/api/docker/logger/base/path")
    public void basePath() {
        renderAPISuccess(loggerService.basePath(getPara("server_id")));
    }

    @Remark("获取文件列表")
    @ActionKey("/api/docker/logger/file/list")
    public void fileList() {
        renderAPISuccess(loggerService.filelist(getPara("server_id"), getPara("base_path"), getPara("file_path")));
    }

    @Remark("读取文件内容")
    @ActionKey("/api/docker/logger/read/last/line")
    public void readLastLines() {
        renderAPISuccess(loggerService.readLastLines(getPara("server_id"), getPara("base_path"), getPara("file_path"), getPara("charset", "UTF-8"), getPara("read_line", "1000"), getPara("start_line")));
    }

}
